<div class="modal-body pageContent">
	<div class="row">
        <div class="col-lg-12 col-lg-offset-2">
            <form id="controllerForm" method="post" class="form-horizontal" action="/controller/EditController">
                <input type="hidden" name="id" value="{{id}}">
                <div class="form-group">
                    <label class="col-lg-12 control-label"><span class="indicator">*</span><span class="indicatorName">控制器SN</span></label>
                    <div class="col-lg-12">
                        <input type="text" class="form-control" name="controllerSn" value="{{controllerSn}}"/>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-lg-12 control-label"><span class="indicator">*</span><span class="indicatorName">IP地址</span></label>
                    <div class="col-lg-12">
                        <input type="text" class="form-control" name="address" value="{{address}}" />
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-lg-12 control-label"><span class="indicator">*</span><span class="indicatorName">单位</span></label>
                    <div class="col-lg-12">
                        <input type="text" class="form-control" name="units" value="{{units}}" />
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
<div class="modal-footer pageFooter">

    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
    <button  class="btn btn-primary"  type="submit" id="displayBtn">保存</button>

</div>
<script>
    $(function(){
        $('#controllerForm')
        .bootstrapValidator({
            message: '此值无效',
            feedbackIcons: {
                valid: 'glyphicon glyphicon-ok',
                invalid: 'glyphicon glyphicon-remove',
                validating: 'glyphicon glyphicon-refresh'
            },
            fields: {
               controllerSn: {
                    message: '请填写控制器SN',
                    validators: {
                        notEmpty: {
                            message: '控制器SN不能为空'
                        }
                    }
                },
                 address: {
                    message: '请填写IP地址',
                    validators: {
                        notEmpty: {
                            message: 'IP地址不能为空'
                        },
                        regexp: { //正则表达式
                        //   regexp: /^(1\d{2}|2[0-4]\d|25[0-5]|[1-9]\d|[1-9])(\.(1\d{2}|2[0-4]\d|25[0-5]|[1-9]\d|\d)){3}$/,
                           regexp: /^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\:([0-9]|[1-9]\d{1,3}|[1-5]\d{4}|6[0-5]{2}[0-3][0-5])$/,
                          message: '请填写正确格式的IP地址'
                        }
                    }
                }, 
                units: {
                    message: '请填写单位',
                    validators: {
                        notEmpty: {
                            message: '单位不能为空'
                        }
                    }
                }
            }
        })
        .on('success.form.bv', function(e) {
            e.preventDefault();
            var $form = $(e.target);
            var bv = $form.data('bootstrapValidator');
            //console.log($form.serialize());
            // Use Ajax to submit form data
            $('#controllerListEdit').formAjax({'url':$form.attr('action'),'data':$form.serializeArray(),'tableRefresh':'#controllerTable'})
            // $.post($form.attr('action'), $form.serialize(), function(result) {
            //     //debugger;
            //     if(result.statusCode =='200'){
            //          toastr.success(result.message+'!');
            //          $('#controllerListEdit').modal('hide');
            //          $("#controllerTable").bootstrapTable('refresh');
            //     }else{
            //         toastr.warning(result.message+'!');
            //     } 
            // }, 'json');
        });
    })
</script>